const webpack = require('webpack');
const merge = require('webpack-merge');//用于合并两个配置文件的工具
const common = require('./webpack.config.js');//加载之前定义的配置文件
const CopyWebpackPlugin = require('copy-webpack-plugin');
const OptimizeCSSAssetsPlugin = require('optimize-css-assets-webpack-plugin');
const path =require('path');

module.exports = merge(common, {
    mode:"production",
    // 输出
    output:{
        filename:'js/[name].[hash].js',
        path:path.resolve(__dirname+ '/dist')
    },
    module:{
       
    },
    optimization: {
        runtimeChunk: {
          "name": "manifest"
        },
        splitChunks: {
          cacheGroups: {
            default: false,
            vendors: false,
            vendor: {
              test: /[\\/]node_modules[\\/]/,
              name: 'vendors',
              chunks: 'all'
            }

          }
        }
    },

    plugins: [
        new CopyWebpackPlugin([ //复制静态资源
          {
            from:'static',
            to:'static'
          }
        ]),

        new OptimizeCSSAssetsPlugin({}), //css压缩
    ],
    devtool: 'source-map'//开启控制台输出错误信息具体在哪行
});
